package com.wandar.gc.schema;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import com.wandar.gc.util.StringUtil;

/**
 * @author huangxm
 * 
 */
public class PropertySchema {
	
	/** 属性名称 */
	private String	propertyName;
	
	/** 属性类型 */
	private String	propertyType;
	
	/**  属性类型包*/
	private String	packageTarget;
	
	/** 是否为主键 */
	private String prikey;
	
	/** mybatis 类型 */
	private String	jdbcType;
	
	/** get set name 首字母大写名称 */
	private String	functionName;
	
	/** 数据库 字段类型 如：varchar */
	private String	dataType;
	
	/** 数据库 描述信息 */
	private String	columnComment;
	
	/** 数据库 字段名称 */
	private String	columnName;
	
	/** 数据库 字段类型详情 如：varchar（20） */
	private String	columnType;
	
	public PropertySchema() {
	}
	
	public String getPropertyName() {
		//转换数据库字段为属性
		if(StringUtils.isNotBlank(columnName)){
			String c = columnName.toLowerCase();
			this.propertyName = StringUtil.getPropertyName(c);
		}
		
		return propertyName;
	}
	
	public void setPropertyName(String propertyName) {
		
		this.propertyName = propertyName;
	}
	
	public String getPropertyType() {
		return propertyType;
	}
	
	public void setPropertyType(String propertyType) {
		this.propertyType = propertyType;
	}
	
	public String getFunctionName() {
		//返回首字母大写的方法名称
		if(StringUtils.isNotBlank(getPropertyName())){
			this.functionName =  StringUtil.firstLetterToUpper(getPropertyName());
		}
		return functionName;
	}
	
	public void setFunctionName(String functionName) {
		this.functionName = functionName;
	}
	
	public String getDataType() {
		return dataType;
	}
	
	public void setDataType(String dataType) {
		this.dataType = dataType;
	}
	
	public String getColumnComment() {
		return columnComment;
	}
	
	public void setColumnComment(String columnComment) {
		this.columnComment = columnComment;
	}
	
	public String getColumnName() {
		return columnName;
	}
	
	public void setColumnName(String columnName) {
		this.columnName = columnName;
	}
	
	public String getColumnType() {
		return columnType;
	}
	
	public void setColumnType(String columnType) {
		this.columnType = columnType;
	}
	
	public String getPackageTarget() {
		return packageTarget;
	}
	
	public void setPackageTarget(String propertyTypePpackage) {
		this.packageTarget = propertyTypePpackage;
	}
	
	public String getJdbcType() {
		return jdbcType;
	}
	
	public void setJdbcType(String jdbcType) {
		this.jdbcType = jdbcType;
	}

	public String getPrikey() {
		return prikey;
	}

	public void setPrikey(String prikey) {
		this.prikey = prikey;
	}

	/**
	 * @return
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
	}
}
